package test.study.java.jol.samples;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

@Slf4j
public class JOLSample_06_HierarchyGaps {

    /*
     * This example shows another HotSpot layout quirk.
     *
     * Prior to JDK 15, HotSpot rounds up the instance field block
     * up to reference size. That unfortunately yields the artificial
     * gaps at the end of the class.
     *
     * In JDK 15 and later, the hierarchy gaps are no longer present.
     *
     * See also:
     *    https://bugs.openjdk.java.net/browse/JDK-8237767
     */

    public static void main(String[] args) {
        log.info(VM.current().details());
        log.info(ClassLayout.parseClass(C.class).toPrintable());
    }

    public static class A {
        boolean a;
    }

    public static class B extends A {
        boolean b;
    }

    public static class C extends B {
        boolean c;
    }
}
